﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<JLL.China.Web.Areas.Listings.Models.LocationModel>" %>

<%@ Import Namespace="System.ComponentModel" %>
<%@ Import Namespace="System.Security.Policy" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <link href="<%=Url.Content("~/Scripts/qtip2/jquery.qtip.min.css") %>" rel="stylesheet"
        type="text/css" />
    <link href="<%=Url.Content("~/Scripts/jquery.validation/validationEngine.jquery.css")%>"
        rel="stylesheet" type="text/css" />
    <link href="<%=Url.Content("~/Scripts/chosen/chosen.css")%>" rel="stylesheet" type="text/css" />
    <link href="<%=Url.Content("~/Content/css/mod-listing.css")%>" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .scrollbox
        {
            height: auto;
            min-width: 580px !important;
            line-height: 18px;
        }
        body
        {
            font: 12px Arial;
        }
    </style>

    <script src="<%=Url.Content("~/Scripts/Utility.js")%>" type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/jquery-1.7.2.js")%>" type="text/javascript"></script>

    <!-- -->

    <script src="<%=Url.Content("~/Scripts/jquery.validation/jquery.validationEngine-en.js")%>"
        type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/jquery.validation/jquery.validationEngine.js")%>"
        type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/chosen/chosen.jquery.min.js")%>" type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/knockout/knockout.js")%>" type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/knockout/knockout.mapping.js")%>" type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/Utility.js")%>" type="text/javascript"></script>

    <script type="text/javascript">
        var BASE_URL = '<%=Url.Content("~/")%>';
        //
        Namespace.Register("System.Data");
   
    </script>

    <script>
var BASE_URL ='<%=Url.Content("~/")%>';
     $(document).ready(function() {
         $("#formID").validationEngine({
             prettySelect: true,
             useSuffix: "_chzn",
             promptPosition: "topLeft"
         });
         $(".chz").chosen({
             allow_single_deselect: true
         });
           $(".chzn-nosearch").chosen({ disable_search_threshold: 3, allow_single_deselect: true });
         
         $.ajaxSetup({ cache: false });
            $("#location_inter").bind("keyup change blur", function() {
                var data = $(this).val();
                var city = $("#city").val();
                if (data.length == 0) {
                    $("#checkitem_inter").text("");
                    $("#checkitem_inter").removeClass("green");
                    $("#checkitem_inter").removeClass("red");
                } else {
                    $.ajax({
                        url: BASE_URL + "Listings/Location/CheckName",
                        type: 'POST', // POST or GET
                        data: { name: data, cityId:city,where:'1'},
                        success: function(result, status) {
                            if (result == "YES") {
                                $("#checkitem_inter").text("That name  is already in use.");
                                $("#checkitem_inter").removeClass("green");
                                $("#checkitem_inter").addClass("red");

                            } else {
                                $("#checkitem_inter").text("");
                                $("#checkitem_inter").removeClass("red");
                                // $(".checkitem").addClass("green");

                            }
                        }
                    }
		);

                }
            });
            
            //check name local
          $.ajaxSetup({ cache: false });
            $("#location_local").bind("keyup change blur", function() {
                var data = $(this).val();
              var city = $("#city").val();
                if (data.length == 0) {
                    $("#checkitem_local").text("");
                    $("#checkitem_local").removeClass("green");
                    $("#checkitem_local").removeClass("red");
                } else {
                    $.ajax({
                        url: BASE_URL + "Listings/Location/CheckName",
                        type: 'POST', // POST or GET
                        data: { name: data, cityId:city,where:'2'},
                        success: function(result, status) {
                            if (result == "YES") {
                                $("#checkitem_local").text("That name is already in use.");
                                $("#checkitem_local").removeClass("green");
                                $("#checkitem_local").addClass("red");

                            } else {
                                $("#checkitem_local").text("");
                                $("#checkitem_local").removeClass("red");
                                // $(".checkitem").addClass("green");

                            }
                        }
                    }
		);

                }
            });
    
});
        <% if(ViewData["SaveAction"]!=null)
           {%>
        window.parent.location.href = window.parent.location.href;
        <% } %>
       
    </script>

    <title>Edit</title>
</head>
<body>
    <% using (Html.BeginForm("Update", "Location", FormMethod.Post, new { id = "formID", enctype = "multipart/form-data", @class = "validateform" }))
       { %>
    <%= Html.HiddenFor(x => x.Location_Inter.LocationID) %>
    <%= Html.HiddenFor(x => x.Location_Local.LocationID) %>
    <%= Html.HiddenFor(x => x.Location_Inter.LanguageFID) %>
    <%= Html.HiddenFor(x => x.Location_Local.LanguageFID) %>
    <% if (Model.Location_Inter != null)
       { %>
    <p>
        <h3 style="margin-left: 8px">
            Update Location Name
        </h3>
    </p>
    <% }
       else
       { %>
    <p>
        <h3 style="margin-left: 8px">
            Insert Location
        </h3>
    </p>
    <% } %>
    <table align="center" cellpadding="10" cellspacing="10" class="style1" style="padding: 5px"
        width="">
        <%--  <% if (Model.Location_Inter == null)
       { %>
        <tr>
            <td style="width: 30%">
                <%--<font color="red">(*)</font>Country
            </td>
            <td style="width: 50%">
                 <select data-bind="options: availableCountry, 
                   optionsCaption:'Please select...',
                   optionsText: 'Country_EN',
                   optionsValue: 'Country_ID'
                   " class="select-size-custom validate[required] chz hide " id="vmCountry"
            name="Country" />
            </td>
        </tr>
        <% }%>--%>
        <tr>
            <td style="width: 30%">
                <font color="red">(*)</font>City
            </td>
            <td style="width: 50%">
                <%=Html.DropDownListFor(x => x.Location_Inter.CityID, new SelectList(Model.CityList, "CityID", "CityName"), new { id = "city", name = "city", @class = "chz", style = "width:350px" })%>
            </td>
        </tr>
        <%--<%Html.RenderPartial("CityLocationSubarea", new string[] { "1", "1","2"}); %>--%>
        <tr>
            <td style="width: 30%">
                <font color="red">(*)</font>Location name( Enlish)
            </td>
            <td style="width: 50%">
                <%= Html.TextBoxFor(x => x.Location_Inter.LocationName,
                                               new
                                                   {
                                                       name = "location_inter",
                                                       id = "location_inter",
                                                       @class = "validate[required] inp-form",
                                                       style = "width: 100%"
                                                   }) %>
                <a class="checkitem" id="checkitem_inter"></a>
            </td>
        </tr>
        <tr>
            <td style="width: 30%">
                <font color="red">(*)</font>Location name( Local)
            </td>
            <td style="width: 50%">
                <%= Html.TextBoxFor(x => x.Location_Local.LocationName,
                                               new
                                                   {
                                                       name = "location_local",
                                                       id = "location_local",
                                                       @class = "validate[required] inp-form",
                                                       style = "width: 100%"
                                                   }) %>
                <a class="checkitem" id="checkitem_local"></a>
            </td>
        </tr>
        <tr>
            <%-- <td style="width:30%">
                <font color="red">(*)</font>City code</td>
              <td style="width:50%">
                  <%= Html.TextBoxFor(x => x.City_Inter.CityCode,
                                               new
                                                   {
                                                       name = "country_cn",
                                                       id = "country_cn",
                                                       @class = "validate[required] inp-form",
                                                       style = "width: 100%"
                                                   }) %></td>--%>
        </tr>
        <%--  <tr>
            <td style="width:30%">
                <font color="red">(*)</font>Status</td>
              <td style="width:50%">
                <%=Html.DropDownListFor(m => m.City_Inter.Status, new List<SelectListItem>
                     {
                        new SelectListItem{Selected = true, Text="Active", Value = "true" }, 
                        new SelectListItem{Selected = false, Text="Inactive", Value = "false" },
                     }, new { id = "city_status", name = "city_status", @class = "chzn-nosearch ", style ="width:200px"})%>
            </td>
        </tr>--%>
        <tr>
            <td>
            </td>
            <td width="20%" align="right">
                <input type="button" value="Cancel" class="buttons" style="margin-right: 18px; float: right;
                    cursor: pointer" onclick="window.parent.location='<%= Url.Content("~/Listings/Location/Index") %>'" />
                <input type="submit" value="Save" class="buttons" style="margin-right: 8px; float: right" />
            </td>
        </tr>
    </table>
    <% } %>
</body>
</html>
